package org.ycx.doc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.ycx.doc.dao.auto.DocProjectMapper;
import org.ycx.doc.dao.auto.DocUserVersionMapper;
import org.ycx.doc.dao.mapper.ProfileMapper;
import org.ycx.doc.dao.model.DocUserVersion;
import org.ycx.doc.dto.DocProjectInfo;
import org.ycx.doc.dto.DocUser;
import org.ycx.doc.service.IProfileService;
import org.ycx.upms.dao.model.SecUser;

import java.util.List;

@Service
@Transactional
public class ProfileService implements IProfileService {

    @Autowired
    private ProfileMapper mapper;

    @Override
    public DocUser findUserProfile(int uid) {
        return this.mapper.findByUid(uid);
    }

    @Override
    public int updateUser(DocUser user) {
        return this.mapper.updateUser(user);
    }

    @Override
    public List<DocProjectInfo> findUserProject(int uid) {
        return this.mapper.findProjectByUid(uid);
    }

    @Override
    public DocProjectInfo addUserVersion(DocUserVersion duv) {
        DocProjectInfo bean = null;
        int res = this.mapper.insertUserVersion(duv);
        if(res > 0){
            bean = this.mapper.findProjectById(duv.getAppId ());
        }
        return bean;
    }

    @Override
    public int updateUserProject(Integer appId, int uid, Integer userVersion) {
        return this.mapper.updateUserProject(appId,uid,userVersion);
    }

    @Override
    public int delUserApp(Integer appId, int uid) {
        return this.mapper.deleteUserApp(appId,uid);
    }
}
